package com.lagou.edu.controller;

import com.lagou.edu.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * @author: jie.zhao
 * @create: 2021/07/31 14:07
 */
@RestController
@RequestMapping("/api/user")
public class UserController {

    @Resource
    UserService userService;

    @GetMapping("/isRegistered/{email}")
    public boolean isRegistered(@PathVariable String email){
        return userService.isRegistered(email);
    }

    @GetMapping("/login/{email}/{password}")
    public String login(@PathVariable String email, @PathVariable String password, HttpServletResponse response){
        return userService.login(email,password,response);
    }

    @GetMapping("/register/{email}/{password}/{code}")
    public String register(@PathVariable String email,@PathVariable String password,@PathVariable String code){
        return userService.register(email,password,code);
    }


}
